<%
Dim MenuID			
Dim ParentID		
Dim MenuName		

Dim MenuPath
Dim MenuVisibled
Dim Menu_Order		

Sub Admin_Sub_Menu_Add()	

	
	ParentID = reform("ParentID")
	MenuName = reform("MenuName")
	MenuPath = reform("MenuPath")
	MenuVisibled = reform("MenuVisibled")

	Call Check_IsNumeric(ParentID)


	Call Check_Length(MenuName,100,1,"菜单名称")

	Call Check_Length(MenuPath,255,1,"脚本路径")
	
	Menu_Order = Get_Max_Order(ParentID)

	sql = "INSERT INTO Admin_Menu(ParentID,MenuName,MenuVisibled,Menu_Order,MenuPath) VALUES( " &_
		  "  " & ParentID &_
		  ",'" & MenuName & "'" &_
		  ",'" & MenuVisibled & "'" &_
		  "," & Menu_Order & _
		  ",'" & MenuPath & "')" 

    conn.execute(sql)

	AlertBox "子菜单增加成功！","Admin_Sub_Menu_Query.asp?ParentID="&ParentID


End Sub
Function Get_Max_Order(ParentID)
	Get_Max_Order = conn.EXECUTE("SELECT ISNULL(MAX(Menu_Order),0)+1 FROM Admin_Menu WHERE ParentID="&ParentID)(0)
End Function 

Sub Admin_Sub_Menu_Edit()	

	MenuID   = reform("MenuID")
	ParentID = reform("ParentID")
	MenuName = reform("MenuName")
	MenuPath = reform("MenuPath")
	MenuVisibled = reform("MenuVisibled")

	Call Check_IsNumeric(MenuID)

	

	Call Check_IsNumeric(ParentID)


	Call Check_Length(MenuName,100,1,"菜单名称")

	Call Check_Length(MenuPath,255,1,"脚本路径")

	sql = "UPDATE Admin_Menu Set " &_
		  " ParentID = " & ParentID &_
		  ",MenuName = '" & MenuName & "'" &_
		  ",MenuPath  = '" & MenuPath & "'" &_
		  ",MenuVisibled  = '" & MenuVisibled & "'" &_
		  " WHERE MenuID = "&MenuID


    conn.execute(sql)

	AlertBox "子菜单修改成功！","Admin_Sub_Menu_Query.asp?ParentID="&ParentID

End Sub

Sub Admin_Sub_Menu_Del()


	MenuID   = Reform("Op_ID")	
	ParentID = requery("ParentID")

	Call Check_IsNumeric(ParentID)

	sql = "DELETE FROM  Admin_Menu WHERE  MenuID IN  ("&MenuID &")"

	On Error Resume Next
		  
    conn.execute(sql)

	if err.number =0 then  
		AlertBox "子菜单删除成功！","Admin_Sub_Menu_Query.asp?ParentID="&ParentID
	else 
		AlertBox "子菜单删除失败！","Admin_Sub_Menu_Query.asp?ParentID="&ParentID
	end if


End Sub

Sub Get_Admin_Sub_Menu_Info(MenuID)


	sql = "SELECT * FROM Admin_Menu WHERE MenuID = " &MenuID

	Set rs = conn.execute(sql)
	
	If Not rs.eof Then

		MenuID   = rs("MenuID")
		ParentID = rs("ParentID")
		MenuName = rs("MenuName")
		MenuPath = rs("MenuPath")
		MenuVisibled = rs("MenuVisibled")
		

	End If
	

End Sub 
%>

